package com.bank.manage.convert;
import com.bank.manage.model.*;
import com.bank.manage.model.dto.RecordsDto;
import org.apache.ibatis.annotations.Param;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * DtoConvert
 *
 * @author grl
 * @date 2024/4/1
 */
@Mapper
public interface DtoConvert {

    /**
     * 获取该类自动生成的实现类的实例
     * 接口中的属性都是 public static final 的 方法都是public abstract的
     */
    DtoConvert INSTANCES = Mappers.getMapper(DtoConvert.class);

    /**
     *  转换成 提现对象
     * @param dto
     * @return
     */
    @Mapping(source = "amount",target = "transferAmount")
    @Mapping(source = "eventTime",target = "tradeTime")
    BankOptCashRecords recordsDtoToOptCash(@Param("dto") RecordsDto dto);

    /**
     * 转换成 消费对象
     * @param dto
     * @return
     */
    @Mapping(source = "eventTime",target = "tradeTime")
    BankOptConsumeRecords recordsDtoToOptConsume(@Param("dto") RecordsDto dto);

    /**
     * 转换成 收入对象
     *
     * @param dto
     * @return
     */
    @Mapping(source = "amount",target = "incomeAmount")
    @Mapping(source = "eventTime",target = "tradeTime")
    BankOptIncomeRecords recordsDtoToOptIncome(@Param("dto") RecordsDto dto);

    /**
     * 转换成充值对象
     * @param dto
     * @return
     */
    @Mapping(source = "eventTime",target = "tradeTime")
    BankOptRechargeRecords recordsDtoToOptRecharge(@Param("dto") RecordsDto dto);

    /**
     * 转换成系统操作对象
     * @param dto
     * @return
     */
    @Mapping(source = "eventTime",target = "eventTime")
    BankOptSysRecords recordsDtoToOptSys(@Param("dto") RecordsDto dto);

    /**
     * 转账类型
     * @param dto
     * @return
     */
    @Mapping(source = "eventTime",target = "tradeTime")
    @Mapping(source = "otherSideWalletNum",target = "payeeWalletNum")
    BankOptTransferRecords recordsDtoToOptTransfer(@Param("dto") RecordsDto dto);
}
